package com.stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;

/**
 * Created by qhe on 2018/8/3.
 */

@EnableBinding(value = {Sink.class,SinkSender.class}) //消息通道（Channel）的绑定,绑定Sink接口。
public class SinkRevice {

    private static Logger logger = LoggerFactory.getLogger(SinkRevice.class);

    /**
     * StreamListener作用是将被修饰的方法注册为消息中间件上数据流的时间监听器
     * 注解中的属性值对应了监听的消息通道名
     * 这里我们通过注解将receive方法注册为input消息通道的监听处理器
     * @param object
     */
    @StreamListener(Sink.INPUT)
    public void receive(Object object){
        logger.info("打印消息："+object);
    }
}
